using System;
using System.Collections.Generic;

namespace CMS.Core.Domain
{
    /// <summary>
    /// NguoiSuDung object for NHibernate mapped table Categories.
    /// </summary>
    /// 
    [Serializable]
    public class NguoiSuDung : DomainObject<System.String>
    {
        private System.String _TenNguoiSuDung;
        private System.String _HoDem = String.Empty;
        private System.String _Ten = String.Empty;
        private System.String _MaPhongBan;
        private System.String _ChucVu;        
        private System.String _TenTruyCap;       
        private System.String _MatKhau;
        private System.String _ChucNang;
        private System.Int32 _MaNhom;
        private System.Boolean _TrangThai = true;
        private System.Int32 _ThuTu;
        private PhongBan _PhongBan;
        private NhomNguoiSuDung _NhomNguoiSuDung;

        private IList<DonThu> _DonThus = new List<DonThu>();
        private IList<ChucNang> _ChucNangs = new List<ChucNang>(); 
        
        public NguoiSuDung()
        {
            base.ID = Guid.NewGuid().ToString().ToUpper();
        }

        public NguoiSuDung(System.String id)
        {
            base.ID = id;
        }

        public virtual System.Int32 ThuTu
        {
            get { return _ThuTu; }
            set { _ThuTu = value; }
        }

        public virtual System.String ChucNang
        {
            get { return _ChucNang; }
            set { _ChucNang = value; }
        }

        public virtual System.Boolean TrangThai
        {
            get { return _TrangThai; }
            set { _TrangThai = value; }
        }

        public virtual System.String TenNguoiSuDung
        {
            get { return _TenNguoiSuDung; }
            set
            {
                _TenNguoiSuDung = value;
                if (!this._TenNguoiSuDung.Equals(String.Empty))
                {
                    this._TenNguoiSuDung = this._TenNguoiSuDung.Trim();
                    int index = this._TenNguoiSuDung.LastIndexOf(" ");
                    if (index != -1)
                    {
                        string ten = this._TenNguoiSuDung.Substring(index, this._TenNguoiSuDung.Length - index).Trim();
                        string hodem = this._TenNguoiSuDung.Replace(ten.Trim(), "").Trim();
                        this.Ten = ten;
                        this.HoDem = hodem;
                    }
                    else
                    {
                        this.Ten = this._TenNguoiSuDung;
                    }
                }
            }
        }

        public virtual System.String HoDem
        {
            get { return _HoDem; }
            set { _HoDem = value; }
        }

        public virtual System.String Ten
        {
            get { return _Ten; }
            set { _Ten = value; }
        }

        public virtual System.String MaPhongBan
        {
            get { return _MaPhongBan; }
            set { _MaPhongBan = value; }
        }

        public virtual System.String ChucVu
        {
            get { return _ChucVu; }
            set { _ChucVu = value; }
        }

        public virtual System.String TenTruyCap
        {
            get { return _TenTruyCap; }
            set { _TenTruyCap = value; }
        }

        public virtual System.String MatKhau
        {
            get { return _MatKhau; }
            set { _MatKhau = value; }
        }


        public virtual System.Int32 MaNhom
        {
            get { return _MaNhom; }
            set { _MaNhom = value; }
        }

        public virtual PhongBan PhongBan
        {
            get { return _PhongBan; }
            set { _PhongBan = value; }
        }

        public virtual IList<DonThu> DonThus
        {
            get { return _DonThus; }
            set { _DonThus = value; }
        }
        
        public virtual NhomNguoiSuDung NhomNguoiSuDung
        {
            get { return _NhomNguoiSuDung; }
            set { _NhomNguoiSuDung = value; }
        }

        public virtual IList<ChucNang> ChucNangs
        {
            get { return _ChucNangs; }
            set { _ChucNangs = value; }
        }

        public override int GetHashCode()
        {
            return ID.GetHashCode();
        }

     }
}
